package com.bjsxt.userscenter.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 需要登陆的Servlet
 * 
 * @author WangshSxt
 *
 */
public class AdminsBackServlet extends HttpServlet
{

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{
		System.out.println("=====AdminsBackServlet==========");
		String method = request.getParameter("method");
		if("main".equalsIgnoreCase(method))
		{
			/* 登陆后的页面 */
			this.main(request,response);
		}else if("logout".equalsIgnoreCase(method))
		{
			/* 退出 */
			this.logout(request,response);
		}
	}

	private void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		/* 退出 */
		request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
		response.sendRedirect(request.getContextPath() + "/login.jsp");
	}

	private void main(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
	{
		/* 客户端跳转 */
		request.getRequestDispatcher("/main.jsp").forward(request, response);
	}
	
	
}
